<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>vue中的Component</title>
</head>
<body>
    <div id="app">
      <aa></aa>
    </div>
    <script src="node_modules/vue/dist/vue.js"></script>
    <script>
        var A = Vue.extend({ //A类似于一个类
           template: "<h3 @click='change'>{{msg}}</h3>",
           data() { //data必须是一个函数，且要返回一个json对象
              return {
                  msg: "我是标题3"
              }
           },
           methods: {
               change: function() {
                   this.msg = "changed"
               }
           }
        });

        Vue.component('aa',A);
      new Vue({
          el: "#app"
      });

    </script>
</body>
</html>